// All_Subject_Information
//ajax获取数据
let xhr = new XMLHttpRequest()
xhr.open("GET", "https://www.bingjs.com:8001/Subject/GetAll")
xhr.send()
xhr.onreadystatechange = function () {
    if (xhr.readyState === 4 && xhr.status === 200) {
        let str = JSON.parse(xhr.response)
        console.log(str);
        getAllSubject(str)
    }
}

// 封装函数 将数据在页面中显示
function getAllSubject(Subject_infor) {
    Subject_infor.forEach(a => {
        let tr = document.createElement("tr")
        let td1 = document.createElement("td")
        td1.innerHTML = a.SubjectId
        let td2 = document.createElement("td")
        td2.innerHTML = a.SubjectName
        let td3 = document.createElement("td")
        td3.innerHTML = a.ClassHour
        let td4 = document.createElement("td")
        td4.innerHTML = a.GradeId
        tr.appendChild(td1)
        tr.appendChild(td2)
        tr.appendChild(td3)
        tr.appendChild(td4)
        document.querySelector("tbody").appendChild(tr)
    })
}